package com.lonely.api.shein.config;


import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.io.Serializable;
import java.util.Objects;

/**
 * httpclient配置
 *
 * @author fzzf
 */
@ConfigurationProperties("shein.open.sdk")
@Data
public class HttpClientConfig implements Serializable {

    /**
     * 开放平台域地址
     */
    private String domain;

    /**
     * HttpClient的连接超时时间
     */
    private long connectTimeoutMillis = 10000;

    /**
     * HttpClient的请求超时时间
     */
    private long requestTimeoutMillis = 10000;

    /**
     * HttpClient的响应超时时间
     */
    private long responseTimeoutMillis = 10000;

    /**
     * 是否自动处理HttpClient的重定向
     */
    private boolean followRedirects = true;

    /**
     * HttpClient的最大连接数
     */
    private int maxConnections = 32;


    @Override
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }
        if (!(object instanceof HttpClientConfig)) {
            return false;
        }
        HttpClientConfig that = (HttpClientConfig) object;
        return connectTimeoutMillis == that.connectTimeoutMillis && responseTimeoutMillis == that.responseTimeoutMillis && followRedirects == that.followRedirects && maxConnections == that.maxConnections && Objects.equals(domain, that.domain);
    }

    @Override
    public int hashCode() {
        return Objects.hash(domain, connectTimeoutMillis, responseTimeoutMillis, followRedirects, maxConnections);
    }
}
